package cate.game.res.holy_pet.core;

import cate.game.res.MixRes;
import easy.java.dev.note.NoteField;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 灵宠单个派遣任务
 *
 * @author ShenSL
 * @since 2023/8/24 23:13
 */
@Data
@NoArgsConstructor
public class HolyPetSingleMission {
    @NoteField("场景ID")
    private int sceneId;
    @NoteField("景点ID")
    private int placeId;
    @NoteField("灵宠ID")
    private int petId;
    @NoteField("开始时间")
    private long startTime;
    @NoteField("结束时间")
    private long endTime;
    @NoteField("下次次检测触发事件的时间")
    private long nextTriggerTime;
    @NoteField("当前机缘事件")
    private List<Integer> adventures;
    @NoteField("已完成机缘事件")
    private List<Integer> doneList;
    @NoteField("当前奖励")
    private MixRes reward;

    /**
     * 添加事件
     */
    public void addAdventure(int id) {
        if (adventures == null) {
            adventures = new ArrayList<>();
        }
        adventures.add(id);
    }

    /**
     * 添加完成事件
     */
    public void addDone(int id) {
        if (doneList == null) {
            doneList = new ArrayList<>();
        }
        doneList.add(id);
    }

    /**
     * 事件是否可随机
     */
    public boolean available(int adventureId) {
        if (adventures != null && adventures.contains(adventureId)) {
            return false;
        }
        return doneList == null || !doneList.contains(adventureId);
    }
}
